package com.example.train.common.utils;

import cn.hutool.core.util.StrUtil;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.TreeMap;

public class RequestUtil {

    public static Map<String, String> getRequestParamsWithSort(HttpServletRequest request) {

        Map<String, String> params = new TreeMap<>();

        Map<String, String[]> parameterMap = request.getParameterMap();

        for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
            params.put(entry.getKey(), StrUtil.join(",", entry.getValue()));
        }

        return params;

    }
}
